package com.my.attendance.dao;

import com.my.attendance.entity.Employee;
import com.my.attendance.entity.Leave;
import com.my.attendance.util.BaseDAO;

import java.util.List;

public class ChaxunDAO extends BaseDAO {
    public List<Leave> getchaxundao() throws Exception {
            String sql="select *from lea;";
        return getList(sql, new Leave(), new Object[0]);
    }

    public List<Leave> getYSEpizhun() throws Exception {
        String sql="select*from lea where status='已批准';";
        return getList2(sql,new Leave(),new Object[0]);
    }

    public List<Leave> getNOpizhun() throws Exception {
        String sql="select*from lea where status='未批准';";
        return getList2(sql,new Leave(),new Object[0]);
    }


    public Leave getChakan(String id) throws Exception {
        String sql="select *from lea where id=?;";
        Object[] obj={id};
        Leave one = getOne(sql, new Leave(), obj);
        return one;
    }

    public Employee getUserName(Integer employee_number) throws Exception {
        String sql ="select * from employee where employee_number=?";
        Object[] obj ={employee_number};
        return getOne(sql,new Employee(),obj);
    }

    public int getPIzhun(String id) throws Exception {
        String sql="update lea set status=? where employee_number=?;";
        Object[] obj={"已批准",id};
        int i = addOrupdOrdel(sql,obj);
        System.out.println("chaxundao收到的："+i);
        return i;
    }
}
